package chap4.Task4_1;

import java.util.Scanner;

/**
 * @author banana
 */
public class UserLogin {
    public static void main(String[] args) {
        /*1 new 用户
        * 2 接受输入
        * 3 判断是否相等*/
        User user=new User("admin","admin");
        for (int i=1;i<=3;i++) {
            //
            System.out.println("请输入用户名");
            Scanner scanner = new Scanner(System.in);
            String name = scanner.nextLine();
            System.out.println("请输入密码");
            String password = scanner.nextLine();
            //判断是否相等
            if(name.equals(user.getName())&& password.equals(user.getPassword())){
                System.out.println("登陆成功");
                //登陆成功之后，玩猜数字游戏
                GussGame.start();
                break;
            }else{
                //不相等分两种情况
                if(i<3){
                    System.out.println("登录失败，还有"+(3-i)+"次机会");
                }else{
                    System.out.println("登陆失败，账号被锁定");
                    break;
                }
            }

        }
    }
}
